<%--
  南京艾瑞
  User: jack
  Date: 2020-06-28
  Time: 18:13
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>index</title>
</head>
<body>

<form action="${pageContext.request.contextPath}/user/formData" method="post">
    用户名称： <input type="text" name="username"><br/>
    用户年龄： <input type="text" name="age"><br/>
    <input type="submit" value="保存">
</form>
<hr>
<script src="${pageContext.request.contextPath}/static/jquery-2.1.1.js"></script>
<button onclick="send()">发起请求</button>
<script>
    function send() {
        $.ajax({
            url: '${pageContext.request.contextPath}/user/json',
            method: 'post',
            contentType: "application/json;charset=utf-8",
            data: '{"name": "jack", "age": "20"}',
            dataType: 'json',

            success: function (data) {
                console.log(data)
            }
        })
    }
</script>
</body>
</html>
